#include <iostream>
#include <string.h>
#include "HttpServer.hpp"

void Login(HttpRequest &req, HttpResponse &resp)
{
    // 根据req，动态构建resp
    LOG(LogLevel::DEBUG) << "进入登录模块" << req.Path() << ", " << req.Args();
}
void Register(HttpRequest &req, HttpResponse &resp)
{
    // 根据req，动态构建resp
    LOG(LogLevel::DEBUG) << "进入注册模块" << req.Path() << ", " << req.Args();
}

void Search(HttpRequest &req, HttpResponse &resp)
{
    // 根据req，动态构建resp
    LOG(LogLevel::DEBUG) << "进入搜索模块" << req.Path() << ", " << req.Args();
}

void Test(HttpRequest &req, HttpResponse &resp)
{
    // 根据req，动态构建resp
    LOG(LogLevel::DEBUG) << "进入测试模块" << req.Path() << ", " << req.Args();
}


int main(int argc,char* argv[])
{
	// daemon(true, false);
	if(argc != 2)
	{
		std::cout << "Usage: " << argv[0] << " port" << std::endl;
		return 1;
	}
	// daemon(true, false);
	
	auto server = std::make_unique<HttpServer>(std::stoi(argv[1]));
	
	server->Resgiter("/login", Login);
	server->Resgiter("/register", Register);
	server->Resgiter("/search", Search);	
	server->Resgiter("/test", Test);
	server->start();	
    return 0;
}